package com.item.redisConfig;

public class TimeUtils {
    public static String getTimeString(final long millisecond) {
        if (millisecond < 1000) {
            return "0" + "秒";
        }
        long second = millisecond / 1000;
        long seconds = second % 60;
        long minutes = second / 60;
        long hours = 0;
        if (minutes >= 60) {
            hours = minutes / 60;
            minutes = minutes % 60;
        }
        String timeString = "";
        String secondString = "";
        String minuteString = "";
        String hourString = "";
        if (seconds < 10) {
            secondString = "0" + seconds + "秒";
        } else {
            secondString = seconds + "秒";
        }
        if (minutes < 10 && hours < 1) {
            minuteString = minutes + "分";
        } else if (minutes < 10) {
            minuteString = "0" + minutes + "分";
        } else {
            minuteString = minutes + "分";
        }
        if (hours < 10) {
            hourString = hours + "时";
        } else {
            hourString = hours + "" + "时";
        }
        if (hours != 0) {
            timeString = hourString + minuteString + secondString;
        } else {
            timeString = minuteString + secondString;
        }
        System.out.println(timeString);
        return timeString;
    }

    public static void main(String[] args) {
        System.out.println(TimeUtils.getTimeString(604800));
    }
}
